Option Strict On
Option Explicit On 

Imports System.Windows.Forms

Imports IP.Core.IPData
Imports IP.Core.IPException
Imports IP.Core.IPDataControl
Imports IP.Core.IPUserService
Imports IP.Core.IPCommon
Imports System

Class f109_ht_nhom_nguoi_su_dung
    Inherits System.Windows.Forms.Form
    Implements I_DisplayableInPanel

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        formatControls()
    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents imageList As System.Windows.Forms.ImageList
    Friend WithEvents m_stb_fms_style As System.Windows.Forms.StatusBar
    Friend WithEvents m_stMess As System.Windows.Forms.StatusBarPanel
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents m_fg_nhom_user As C1.Win.C1FlexGrid.C1FlexGrid
    Friend WithEvents m_Panel_icon_usergroup As System.Windows.Forms.Panel
    Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
    Friend WithEvents Panel1 As System.Windows.Forms.Panel
    Friend WithEvents m_panel As System.Windows.Forms.Panel
    Friend WithEvents m_cmd_xoa As SIS.Controls.Button.SiSButton
    Friend WithEvents Panel2 As System.Windows.Forms.Panel
    Friend WithEvents m_cmd_them As SIS.Controls.Button.SiSButton
    Friend WithEvents m_cmd_sua As SIS.Controls.Button.SiSButton
    Friend WithEvents m_fg_phan_quyen_he_thong As C1.Win.C1FlexGrid.C1FlexGrid
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents cmd_thoat As SIS.Controls.Button.SiSButton
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(f109_ht_nhom_nguoi_su_dung))
        Me.imageList = New System.Windows.Forms.ImageList(Me.components)
        Me.m_stb_fms_style = New System.Windows.Forms.StatusBar
        Me.m_stMess = New System.Windows.Forms.StatusBarPanel
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.m_fg_nhom_user = New C1.Win.C1FlexGrid.C1FlexGrid
        Me.m_Panel_icon_usergroup = New System.Windows.Forms.Panel
        Me.Label1 = New System.Windows.Forms.Label
        Me.m_panel = New System.Windows.Forms.Panel
        Me.m_cmd_xoa = New SIS.Controls.Button.SiSButton
        Me.m_cmd_them = New SIS.Controls.Button.SiSButton
        Me.m_cmd_sua = New SIS.Controls.Button.SiSButton
        Me.GroupBox2 = New System.Windows.Forms.GroupBox
        Me.m_fg_phan_quyen_he_thong = New C1.Win.C1FlexGrid.C1FlexGrid
        Me.Panel2 = New System.Windows.Forms.Panel
        Me.cmd_thoat = New SIS.Controls.Button.SiSButton
        Me.Panel1 = New System.Windows.Forms.Panel
        Me.Label2 = New System.Windows.Forms.Label
        CType(Me.m_stMess, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.GroupBox1.SuspendLayout()
        CType(Me.m_fg_nhom_user, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.m_Panel_icon_usergroup.SuspendLayout()
        Me.m_panel.SuspendLayout()
        Me.GroupBox2.SuspendLayout()
        CType(Me.m_fg_phan_quyen_he_thong, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.Panel2.SuspendLayout()
        Me.Panel1.SuspendLayout()
        Me.SuspendLayout()
        '
        'imageList
        '
        Me.imageList.ImageStream = CType(resources.GetObject("imageList.ImageStream"), System.Windows.Forms.ImageListStreamer)
        Me.imageList.TransparentColor = System.Drawing.Color.Transparent
        Me.imageList.Images.SetKeyName(0, "")
        Me.imageList.Images.SetKeyName(1, "")
        Me.imageList.Images.SetKeyName(2, "")
        Me.imageList.Images.SetKeyName(3, "")
        Me.imageList.Images.SetKeyName(4, "")
        Me.imageList.Images.SetKeyName(5, "")
        Me.imageList.Images.SetKeyName(6, "")
        Me.imageList.Images.SetKeyName(7, "")
        Me.imageList.Images.SetKeyName(8, "")
        Me.imageList.Images.SetKeyName(9, "")
        '
        'm_stb_fms_style
        '
        Me.m_stb_fms_style.ImeMode = System.Windows.Forms.ImeMode.NoControl
        Me.m_stb_fms_style.Location = New System.Drawing.Point(0, 503)
        Me.m_stb_fms_style.Name = "m_stb_fms_style"
        Me.m_stb_fms_style.Panels.AddRange(New System.Windows.Forms.StatusBarPanel() {Me.m_stMess})
        Me.m_stb_fms_style.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.m_stb_fms_style.ShowPanels = True
        Me.m_stb_fms_style.Size = New System.Drawing.Size(878, 22)
        Me.m_stb_fms_style.TabIndex = 20
        Me.m_stb_fms_style.Text = "statusBar"
        '
        'm_stMess
        '
        Me.m_stMess.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
        Me.m_stMess.Icon = CType(resources.GetObject("m_stMess.Icon"), System.Drawing.Icon)
        Me.m_stMess.Name = "m_stMess"
        Me.m_stMess.Width = 861
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.m_fg_nhom_user)
        Me.GroupBox1.Controls.Add(Me.m_Panel_icon_usergroup)
        Me.GroupBox1.Controls.Add(Me.m_panel)
        Me.GroupBox1.Dock = System.Windows.Forms.DockStyle.Left
        Me.GroupBox1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.GroupBox1.Location = New System.Drawing.Point(0, 0)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(484, 503)
        Me.GroupBox1.TabIndex = 22
        Me.GroupBox1.TabStop = False
        '
        'm_fg_nhom_user
        '
        Me.m_fg_nhom_user.AllowAddNew = True
        Me.m_fg_nhom_user.ColumnInfo = resources.GetString("m_fg_nhom_user.ColumnInfo")
        Me.m_fg_nhom_user.Dock = System.Windows.Forms.DockStyle.Fill
        Me.m_fg_nhom_user.KeyActionEnter = C1.Win.C1FlexGrid.KeyActionEnum.MoveAcross
        Me.m_fg_nhom_user.Location = New System.Drawing.Point(3, 68)
        Me.m_fg_nhom_user.Name = "m_fg_nhom_user"
        Me.m_fg_nhom_user.Rows.Count = 41
        Me.m_fg_nhom_user.Size = New System.Drawing.Size(478, 398)
        Me.m_fg_nhom_user.Styles = New C1.Win.C1FlexGrid.CellStyleCollection(resources.GetString("m_fg_nhom_user.Styles"))
        Me.m_fg_nhom_user.TabIndex = 3
        '
        'm_Panel_icon_usergroup
        '
        Me.m_Panel_icon_usergroup.Controls.Add(Me.Label1)
        Me.m_Panel_icon_usergroup.Dock = System.Windows.Forms.DockStyle.Top
        Me.m_Panel_icon_usergroup.Location = New System.Drawing.Point(3, 16)
        Me.m_Panel_icon_usergroup.Name = "m_Panel_icon_usergroup"
        Me.m_Panel_icon_usergroup.Padding = New System.Windows.Forms.Padding(5)
        Me.m_Panel_icon_usergroup.Size = New System.Drawing.Size(478, 52)
        Me.m_Panel_icon_usergroup.TabIndex = 4
        '
        'Label1
        '
        Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.Label1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.Label1.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.Image = CType(resources.GetObject("Label1.Image"), System.Drawing.Image)
        Me.Label1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.Label1.Location = New System.Drawing.Point(5, 5)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(468, 42)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "Các nhóm người sử dụng School Management"
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'm_panel
        '
        Me.m_panel.Controls.Add(Me.m_cmd_xoa)
        Me.m_panel.Controls.Add(Me.m_cmd_them)
        Me.m_panel.Controls.Add(Me.m_cmd_sua)
        Me.m_panel.Dock = System.Windows.Forms.DockStyle.Bottom
        Me.m_panel.Location = New System.Drawing.Point(3, 466)
        Me.m_panel.Name = "m_panel"
        Me.m_panel.Padding = New System.Windows.Forms.Padding(4)
        Me.m_panel.Size = New System.Drawing.Size(478, 34)
        Me.m_panel.TabIndex = 5
        '
        'm_cmd_xoa
        '
        Me.m_cmd_xoa.AdjustImageLocation = New System.Drawing.Point(0, 0)
        Me.m_cmd_xoa.BtnShape = SIS.Controls.Button.emunType.BtnShape.Rectangle
        Me.m_cmd_xoa.BtnStyle = SIS.Controls.Button.emunType.XPStyle.[Default]
        Me.m_cmd_xoa.Dock = System.Windows.Forms.DockStyle.Right
        Me.m_cmd_xoa.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.m_cmd_xoa.ImageIndex = 4
        Me.m_cmd_xoa.ImageList = Me.imageList
        Me.m_cmd_xoa.Location = New System.Drawing.Point(242, 4)
        Me.m_cmd_xoa.Name = "m_cmd_xoa"
        Me.m_cmd_xoa.Size = New System.Drawing.Size(72, 26)
        Me.m_cmd_xoa.TabIndex = 18
        Me.m_cmd_xoa.Text = "&Xoá "
        '
        'm_cmd_them
        '
        Me.m_cmd_them.AdjustImageLocation = New System.Drawing.Point(0, 0)
        Me.m_cmd_them.BtnShape = SIS.Controls.Button.emunType.BtnShape.Rectangle
        Me.m_cmd_them.BtnStyle = SIS.Controls.Button.emunType.XPStyle.[Default]
        Me.m_cmd_them.Dock = System.Windows.Forms.DockStyle.Right
        Me.m_cmd_them.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.m_cmd_them.ImageIndex = 2
        Me.m_cmd_them.ImageList = Me.imageList
        Me.m_cmd_them.Location = New System.Drawing.Point(314, 4)
        Me.m_cmd_them.Name = "m_cmd_them"
        Me.m_cmd_them.Size = New System.Drawing.Size(80, 26)
        Me.m_cmd_them.TabIndex = 17
        Me.m_cmd_them.Text = "Thê&m"
        '
        'm_cmd_sua
        '
        Me.m_cmd_sua.AdjustImageLocation = New System.Drawing.Point(0, 0)
        Me.m_cmd_sua.BtnShape = SIS.Controls.Button.emunType.BtnShape.Rectangle
        Me.m_cmd_sua.BtnStyle = SIS.Controls.Button.emunType.XPStyle.[Default]
        Me.m_cmd_sua.Dock = System.Windows.Forms.DockStyle.Right
        Me.m_cmd_sua.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.m_cmd_sua.ImageIndex = 3
        Me.m_cmd_sua.ImageList = Me.imageList
        Me.m_cmd_sua.Location = New System.Drawing.Point(394, 4)
        Me.m_cmd_sua.Name = "m_cmd_sua"
        Me.m_cmd_sua.Size = New System.Drawing.Size(80, 26)
        Me.m_cmd_sua.TabIndex = 16
        Me.m_cmd_sua.Text = "&Sửa"
        '
        'GroupBox2
        '
        Me.GroupBox2.Controls.Add(Me.m_fg_phan_quyen_he_thong)
        Me.GroupBox2.Controls.Add(Me.Panel2)
        Me.GroupBox2.Controls.Add(Me.Panel1)
        Me.GroupBox2.Dock = System.Windows.Forms.DockStyle.Fill
        Me.GroupBox2.Location = New System.Drawing.Point(484, 0)
        Me.GroupBox2.Name = "GroupBox2"
        Me.GroupBox2.Size = New System.Drawing.Size(394, 503)
        Me.GroupBox2.TabIndex = 23
        Me.GroupBox2.TabStop = False
        '
        'm_fg_phan_quyen_he_thong
        '
        Me.m_fg_phan_quyen_he_thong.AllowAddNew = True
        Me.m_fg_phan_quyen_he_thong.ColumnInfo = resources.GetString("m_fg_phan_quyen_he_thong.ColumnInfo")
        Me.m_fg_phan_quyen_he_thong.Dock = System.Windows.Forms.DockStyle.Fill
        Me.m_fg_phan_quyen_he_thong.KeyActionEnter = C1.Win.C1FlexGrid.KeyActionEnum.MoveAcross
        Me.m_fg_phan_quyen_he_thong.Location = New System.Drawing.Point(3, 68)
        Me.m_fg_phan_quyen_he_thong.Name = "m_fg_phan_quyen_he_thong"
        Me.m_fg_phan_quyen_he_thong.Rows.Count = 42
        Me.m_fg_phan_quyen_he_thong.Size = New System.Drawing.Size(388, 398)
        Me.m_fg_phan_quyen_he_thong.Styles = New C1.Win.C1FlexGrid.CellStyleCollection(resources.GetString("m_fg_phan_quyen_he_thong.Styles"))
        Me.m_fg_phan_quyen_he_thong.TabIndex = 22
        '
        'Panel2
        '
        Me.Panel2.Controls.Add(Me.cmd_thoat)
        Me.Panel2.Dock = System.Windows.Forms.DockStyle.Bottom
        Me.Panel2.Location = New System.Drawing.Point(3, 466)
        Me.Panel2.Name = "Panel2"
        Me.Panel2.Padding = New System.Windows.Forms.Padding(4)
        Me.Panel2.Size = New System.Drawing.Size(388, 34)
        Me.Panel2.TabIndex = 24
        '
        'cmd_thoat
        '
        Me.cmd_thoat.AdjustImageLocation = New System.Drawing.Point(0, 0)
        Me.cmd_thoat.BtnShape = SIS.Controls.Button.emunType.BtnShape.Rectangle
        Me.cmd_thoat.BtnStyle = SIS.Controls.Button.emunType.XPStyle.[Default]
        Me.cmd_thoat.Dock = System.Windows.Forms.DockStyle.Right
        Me.cmd_thoat.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.cmd_thoat.ImageIndex = 6
        Me.cmd_thoat.ImageList = Me.imageList
        Me.cmd_thoat.Location = New System.Drawing.Point(296, 4)
        Me.cmd_thoat.Name = "cmd_thoat"
        Me.cmd_thoat.Size = New System.Drawing.Size(88, 26)
        Me.cmd_thoat.TabIndex = 15
        Me.cmd_thoat.Text = "&Thoát"
        Me.cmd_thoat.Visible = False
        '
        'Panel1
        '
        Me.Panel1.Controls.Add(Me.Label2)
        Me.Panel1.Dock = System.Windows.Forms.DockStyle.Top
        Me.Panel1.Location = New System.Drawing.Point(3, 16)
        Me.Panel1.Name = "Panel1"
        Me.Panel1.Padding = New System.Windows.Forms.Padding(5)
        Me.Panel1.Size = New System.Drawing.Size(388, 52)
        Me.Panel1.TabIndex = 23
        '
        'Label2
        '
        Me.Label2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.Label2.Dock = System.Windows.Forms.DockStyle.Fill
        Me.Label2.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label2.Image = CType(resources.GetObject("Label2.Image"), System.Drawing.Image)
        Me.Label2.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.Label2.Location = New System.Drawing.Point(5, 5)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(378, 42)
        Me.Label2.TabIndex = 2
        Me.Label2.Text = "Phân quyền Hệ thống"
        Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'f109_ht_nhom_nguoi_su_dung
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(878, 525)
        Me.Controls.Add(Me.GroupBox2)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.m_stb_fms_style)
        Me.Name = "f109_ht_nhom_nguoi_su_dung"
        Me.Text = "M109 - Quan ly vai tro su dung"
        CType(Me.m_stMess, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupBox1.ResumeLayout(False)
        CType(Me.m_fg_nhom_user, System.ComponentModel.ISupportInitialize).EndInit()
        Me.m_Panel_icon_usergroup.ResumeLayout(False)
        Me.m_panel.ResumeLayout(False)
        Me.GroupBox2.ResumeLayout(False)
        CType(Me.m_fg_phan_quyen_he_thong, System.ComponentModel.ISupportInitialize).EndInit()
        Me.Panel2.ResumeLayout(False)
        Me.Panel1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

#Region "Member"

    Private m_obj_transfer_right As ITransferDataRow
    Private m_ds_ht_usergroup As DS_HT_NHOM_NGUOI_SU_DUNG
    Private m_ds_ht_right As DS_HT_PHAN_QUYEN_HE_THONG
    Private m_ds_ht_right_cho_nhom As DS_HT_PHAN_QUYEN_CHO_NHOM
    Private m_message_handler As IPStatusBarMessages
#End Region

#Region "Data Structures"
    Private Enum ColNumberRight
        Thuoc_loai = 1
        Ma_phan_quyen = 2
        Duoc_gan = 3
        ID = 4
    End Enum
    Private Enum ColNumberUserGroup
        Trang_Thai = 1
        Ma_UserGroup = 2
        Ghi_chu = 3
        ID = 4
    End Enum
#End Region


#Region "Private Methods"


    Private Sub formatControls()
        'IP.Core.IPCommon.CControlFormat.setFormStyle(Me, New CApplicationContext, IPFormStyle.DialogForm)
        IP.Core.IPCommon.CControlFormat.setFormStyle(Me, IPFormStyle.DialogForm)
        IPCommon.CControlFormat.setC1FlexFormat(Me.m_fg_nhom_user, C1GridStyle.GridViewAndSearch)
        IPCommon.CControlFormat.setC1FlexFormat(Me.m_fg_phan_quyen_he_thong, C1GridStyle.GridViewAndSearch)
        m_fg_phan_quyen_he_thong.AllowSorting = C1.Win.C1FlexGrid.AllowSortingEnum.None
        m_fg_phan_quyen_he_thong.Cols(ColNumberRight.Thuoc_loai).AllowMerging = True
        m_message_handler = New IPStatusBarMessages(m_stb_fms_style)

    End Sub

    Private Function getMappingCol_TrangThai() As Hashtable
        Dim v_hst As New Hashtable
        v_hst.Add(True, "IN_USE")
        v_hst.Add(False, "NOT_IN_USE")
        Return v_hst
    End Function

    Private Function right_is_granted(ByVal i_dc_id_nhom_user As Decimal, ByVal i_dc_id_right As Decimal) As Boolean
        Dim v_data_view As New DataView(m_ds_ht_right_cho_nhom.HT_PHAN_QUYEN_CHO_NHOM, _
                                         "NHOM_NGUOI_SU_DUNG_ID = " & i_dc_id_nhom_user & " AND  " & _
                                         " PHAN_QUYEN_HE_THONG_ID = " & i_dc_id_right, _
                                         "ID", DataViewRowState.CurrentRows)
        Return v_data_view.Count > 0
    End Function


    Private Function get_trans_obj_right() As ITransferDataRow
        Dim v_hasttable As New Hashtable
        v_hasttable.Add(IPData.IPDBName.HT_PHAN_QUYEN_HE_THONG.MA_PHAN_QUYEN, ColNumberRight.Ma_phan_quyen)
        v_hasttable.Add(IPData.IPDBName.HT_PHAN_QUYEN_HE_THONG.LOAI_PHAN_QUYEN, ColNumberRight.Thuoc_loai)
        v_hasttable.Add(IPData.IPDBName.HT_PHAN_QUYEN_HE_THONG.ID, ColNumberRight.ID)
        Dim v_dr_right As DataRow = (New DS_HT_PHAN_QUYEN_HE_THONG).HT_PHAN_QUYEN_HE_THONG.NewRow
        Dim v_obj_trans As New CC1TransferDataRow(m_fg_phan_quyen_he_thong, v_hasttable, v_dr_right)
        Return v_obj_trans
    End Function

    Private Sub load_data_sets()

        Dim v_us_nhom_nguoi_su_dung As New US_HT_NHOM_NGUOI_SU_DUNG
        Try
            m_ds_ht_usergroup = New DS_HT_NHOM_NGUOI_SU_DUNG
            v_us_nhom_nguoi_su_dung.open_connection()
            v_us_nhom_nguoi_su_dung.FillDataset(m_ds_ht_usergroup)

            m_ds_ht_right = New DS_HT_PHAN_QUYEN_HE_THONG
            Dim v_us_ht_right As New US_HT_PHAN_QUYEN_HE_THONG
            v_us_ht_right.use_connection(v_us_nhom_nguoi_su_dung.get_connection)
            v_us_ht_right.FillDataset(m_ds_ht_right, "where 1 = 1 order by " & IPData.IPDBName.HT_PHAN_QUYEN_HE_THONG.LOAI_PHAN_QUYEN)

            m_ds_ht_right_cho_nhom = New DS_HT_PHAN_QUYEN_CHO_NHOM
            Dim v_us_ht_pq_cho_nhom As New US_HT_PHAN_QUYEN_CHO_NHOM
            v_us_ht_pq_cho_nhom.use_connection(v_us_nhom_nguoi_su_dung.get_connection)
            v_us_ht_pq_cho_nhom.FillDataset(m_ds_ht_right_cho_nhom)

            v_us_nhom_nguoi_su_dung.commit_close_connection()
        Catch v_e As Exception
            v_us_nhom_nguoi_su_dung.rollback_close_connection()
            Throw v_e
        End Try
    End Sub
    Private Sub LoadData_2_Grid()
        Try
            load_data_sets()

            RemoveHandler m_fg_nhom_user.AfterRowColChange, AddressOf Me.m_fg_nhom_user_AfterRowColChange
            ' đổ dữ liệu ra grid usergroup
            Dim v_hast_table_boolean As Hashtable = Me.getMappingCol_TrangThai
            m_fg_nhom_user.Redraw = False
            CGridUtils.ClearDataInGrid(m_fg_nhom_user)
            Dim v_dr_nhom_user As DataRow
            Dim v_i_current_row As Integer = m_fg_nhom_user.Rows.Fixed
            For Each v_dr_nhom_user In m_ds_ht_usergroup.HT_NHOM_NGUOI_SU_DUNG.Rows
                m_fg_nhom_user.Rows.Add()
                m_fg_nhom_user(v_i_current_row, ColNumberUserGroup.Trang_Thai) = CIPConvert.ToBoolean(CType(v_dr_nhom_user(IPDBName.HT_NHOM_NGUOI_SU_DUNG.TRANG_THAI_NHOM), String), v_hast_table_boolean)
                m_fg_nhom_user(v_i_current_row, ColNumberUserGroup.Ma_UserGroup) = CType(v_dr_nhom_user(IPDBName.HT_NHOM_NGUOI_SU_DUNG.MA_NHOM), String)
                m_fg_nhom_user(v_i_current_row, ColNumberUserGroup.Ghi_chu) = CType(v_dr_nhom_user(IPDBName.HT_NHOM_NGUOI_SU_DUNG.GHI_CHU), String)
                m_fg_nhom_user(v_i_current_row, ColNumberUserGroup.ID) = CType(v_dr_nhom_user(IPDBName.HT_NHOM_NGUOI_SU_DUNG.ID), Decimal)
                m_fg_nhom_user.Rows(v_i_current_row).UserData = v_dr_nhom_user
                v_i_current_row += 1
            Next
            m_fg_nhom_user.Redraw = True
            'Đổ dữ liệu ra fms right
            m_obj_transfer_right = get_trans_obj_right()
            CGridUtils.Dataset2C1Grid(m_ds_ht_right, m_fg_phan_quyen_he_thong, m_obj_transfer_right)
            '
            AddHandler m_fg_nhom_user.AfterRowColChange, AddressOf Me.m_fg_nhom_user_AfterRowColChange
            display_granted_rights_for_first_usergroup()
        Catch v_e As Exception
            Dim v_err_handler As New CDBExceptionHandler(v_e, New CDBClientDBExceptionInterpret)
            v_err_handler.showErrorMessage()
        End Try
    End Sub

    Private Sub display_granted_rights(ByVal i_dc_id_usergroup As Decimal)
        Dim v_i_current_row As Integer
        For v_i_current_row = m_fg_phan_quyen_he_thong.Rows.Fixed To m_fg_phan_quyen_he_thong.Rows.Count - 1
            Dim v_dc_id_phan_quyen As Decimal = CType(m_fg_phan_quyen_he_thong(v_i_current_row, ColNumberRight.ID), Decimal)
            m_fg_phan_quyen_he_thong(v_i_current_row, ColNumberRight.Duoc_gan) = Me.right_is_granted(i_dc_id_usergroup, v_dc_id_phan_quyen)
        Next
    End Sub

    Private Sub display_granted_rights_for_first_usergroup()
        If Not CGridUtils.IsThere_Any_NonFixed_Row(m_fg_nhom_user) Then Exit Sub
        CGridUtils.stand_on_TopLeft_Cell(m_fg_nhom_user)
        Dim v_dc_id_usergroup As Decimal = CType(m_fg_nhom_user(m_fg_nhom_user.Rows.Fixed, ColNumberUserGroup.ID), Decimal)
        display_granted_rights(v_dc_id_usergroup)
    End Sub

    Private Sub gridrow_to_usergroup_us(ByVal i_us_usergroup As US_HT_NHOM_NGUOI_SU_DUNG, ByVal i_row_index As Integer)
        Dim v_dr_usergroup As DataRow = CType(m_fg_nhom_user.Rows(i_row_index).UserData, DataRow)
        i_us_usergroup.DataRow2Me(v_dr_usergroup)
    End Sub

    Private Sub insert_usergroup()
        Dim v_us_user_group As New US_HT_NHOM_NGUOI_SU_DUNG
        gridrow_to_usergroup_us(v_us_user_group, m_fg_nhom_user.Row)

        Try
            v_us_user_group.open_connection()
            Dim v_frm_de As New f110_nhom_nguoi_su_dung_DE
            Dim v_result As DialogResult
            v_frm_de.insert_usergroup(v_us_user_group, v_result)
            Select Case v_result
                Case DialogResult.OK
                    v_us_user_group.commit_close_connection()
                    LoadData_2_Grid()
                Case DialogResult.Cancel
                    v_us_user_group.rollback_close_connection()
            End Select
        Catch v_ex As Exception
            v_us_user_group.rollback_close_connection()
            Dim v_err_handler As New CDBExceptionHandler(v_ex, New CDBClientDBExceptionInterpret)
            v_err_handler.showErrorMessage()
        End Try

    End Sub

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' sửa 1 usergroup
    ''' </summary>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	[csung]	2/22/2005	Created
    ''' </history>
    ''' 
    ''' -----------------------------------------------------------------------------
    Private Sub update_usergroup()
        If Not CGridUtils.IsThere_Any_NonFixed_Row(m_fg_nhom_user) Then Exit Sub
        If Not CGridUtils.isValid_NonFixed_RowIndex(m_fg_nhom_user, m_fg_nhom_user.Row) Then Exit Sub
        Dim v_us_user_group As New US_HT_NHOM_NGUOI_SU_DUNG
        gridrow_to_usergroup_us(v_us_user_group, m_fg_nhom_user.Row)

        Try
            v_us_user_group.open_connection()
            v_us_user_group.PrepareUpdate()
            Dim v_frm_de As New f110_nhom_nguoi_su_dung_DE
            Dim v_result As DialogResult
            v_frm_de.update_usergroup(v_us_user_group, m_ds_ht_right, v_result)
            Select Case v_result
                Case DialogResult.OK
                    v_us_user_group.commit_close_connection()
                    Dim v_i_old_row_index As Integer = m_fg_nhom_user.Row
                    LoadData_2_Grid()
                    m_fg_nhom_user.Row = v_i_old_row_index
                    m_message_handler.display_message(EnumCommonMessage.DATA_SUBMITTED)
                Case DialogResult.Cancel
                    v_us_user_group.rollback_close_connection()
            End Select
        Catch v_ex As Exception
            v_us_user_group.rollback_close_connection()
            Dim v_err_handler As New CDBExceptionHandler(v_ex, New CDBClientDBExceptionInterpret)
            v_err_handler.showErrorMessage()
        End Try
    End Sub

    Private Sub delete_usergroup()
        If Not CGridUtils.IsThere_Any_NonFixed_Row(m_fg_nhom_user) Then Exit Sub
        If Not CGridUtils.isValid_NonFixed_RowIndex(m_fg_nhom_user, m_fg_nhom_user.Row) Then Exit Sub
        Dim v_us_user_group As New US_HT_NHOM_NGUOI_SU_DUNG
        gridrow_to_usergroup_us(v_us_user_group, m_fg_nhom_user.Row)
        Try
            v_us_user_group.open_connection()
            v_us_user_group.PrepareUpdate()
            v_us_user_group.DeleteByID(v_us_user_group.dcID)
            v_us_user_group.commit_close_connection()
            m_fg_nhom_user.Rows.Remove(m_fg_nhom_user.Row)
        Catch v_ex As Exception
            v_us_user_group.rollback_close_connection()
            Dim v_err_handler As New CDBExceptionHandler(v_ex, New CDBClientDBExceptionInterpret)
            v_err_handler.showErrorMessage()
        End Try
    End Sub

#End Region


#Region "PUBLIC"
    Public Sub display_user_groups()
        Me.ShowDialog()
    End Sub

    Public Sub display_in_panel() Implements I_DisplayableInPanel.display_in_panel
        Me.Show()
    End Sub

#End Region
    '
    ' event handlers
    '
    '

    Private Sub m_cmd_xoa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_cmd_xoa.Click
        Try
            delete_usergroup()
        Catch v_ex As Exception
            CSystemLog_301.ExceptionHandle(v_ex)
        End Try
    End Sub

    Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
        Try
            LoadData_2_Grid()
        Catch v_ex As Exception
            CSystemLog_301.ExceptionHandle(v_ex)
        End Try
    End Sub

    Private Sub m_fg_nhom_user_AfterRowColChange(ByVal sender As Object, ByVal e As C1.Win.C1FlexGrid.RangeEventArgs)
        Try
            If e.NewRange.r1 = e.OldRange.r1 Then Exit Sub
            Dim v_dc_id_usergroup As Decimal = CType(m_fg_nhom_user(e.NewRange.r1, ColNumberUserGroup.ID), Decimal)
            display_granted_rights(v_dc_id_usergroup)
        Catch v_ex As Exception
            CSystemLog_301.ExceptionHandle(v_ex)
        End Try
    End Sub

    Private Sub m_cmd_sua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_cmd_sua.Click
        Try
            update_usergroup()
        Catch v_ex As Exception
            CSystemLog_301.ExceptionHandle(v_ex)
        End Try
    End Sub

    Private Sub cmd_thoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_thoat.Click
        Try
            Me.Close()
        Catch v_ex As Exception
            CSystemLog_301.ExceptionHandle(v_ex)
        End Try
    End Sub

    Private Sub m_cmd_them_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_cmd_them.Click
        insert_usergroup()
    End Sub

    Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)
        Select Case e.KeyCode
            Case Keys.Escape
                Me.Close()
        End Select
    End Sub


   
End Class
